import sympy as sym
import math

from sympy import Min, Matrix, oo

# todo:
# 别的形式 
# M = min(A,[],nanflag)
# M = min(A,[],dim)
# M = min(A,[],dim,nanflag)
# M = min(A,[],'all')
# M = min(A,[],'all',nanflag)
# C = min(A,B)
# C = min(A,B,nanflag)

def my_min(A):
    """返回符号输入 A 的最小值"""
    
    # 判断 A 是否为向量或矩阵
    if isinstance(A, list) or isinstance(A, tuple):
        # A 是向量
        return Min(*A)
    elif isinstance(A, Matrix):
        # A 是矩阵，返回每列的最小值
        max_vals = []
        for j in range(A.shape[1]):
            max_vals.append(Min(*A[:,j]))
        return Matrix(max_vals).T
    else:
        # A 既不是向量也不是矩阵，直接返回 A
        return A
    
x = sym.symbols('x')
A = [1,2,30,4,x]
print(my_min(A))